home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / test / pixmap.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  2.7 KB  |  92 lines

  1. //
  2. // "$Id: pixmap.cxx,v 1.4 1999/01/07 19:17:59 mike Exp $"
  3. //
  4. // Pixmap label test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include <FL/Fl.H>
  27. #include <FL/Fl_Window.H>
  28. #include <FL/Fl_Button.H>
  29. #include <FL/Fl_Pixmap.H>
  30. #include <stdio.h>
  31.  
  32. #include "porsche.xpm"
  33.  
  34. #include <FL/Fl_Toggle_Button.H>
  35.  
  36. Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb;
  37. Fl_Button *b;
  38. Fl_Window *w;
  39.  
  40. void button_cb(Fl_Widget *,void *) {
  41.   int i = 0;
  42.   if (leftb->value()) i |= FL_ALIGN_LEFT;
  43.   if (rightb->value()) i |= FL_ALIGN_RIGHT;
  44.   if (topb->value()) i |= FL_ALIGN_TOP;
  45.   if (bottomb->value()) i |= FL_ALIGN_BOTTOM;
  46.   if (insideb->value()) i |= FL_ALIGN_INSIDE;
  47.   b->align(i);
  48.   w->redraw();
  49. }
  50.  
  51. int dvisual = 0;
  52. int arg(int, char **argv, int &i) {
  53.   if (argv[i][1] == '8') {dvisual = 1; i++; return 1;}
  54.   return 0;
  55. }
  56.  
  57. #include <FL/Fl_Multi_Label.H>
  58.  
  59. Fl_Multi_Label multi = {
  60.   0, "This is the text", 0, FL_NORMAL_LABEL
  61. };
  62.  
  63. int main(int argc, char **argv) {
  64.   int i = 1;
  65.   if (Fl::args(argc,argv,i,arg) < argc)
  66.     Fl::fatal(" -8 # : use default visual\n%s\n",Fl::help);
  67.  
  68.   Fl_Window window(400,400); ::w = &window;
  69.   Fl_Button b(140,160,120,120,0); ::b = &b;
  70.   (new Fl_Pixmap(porsche_xpm))->label(&b);
  71.   multi.labela = b.label(); multi.typea = b.labeltype(); multi.label(&b);
  72.   leftb = new Fl_Toggle_Button(50,75,50,25,"left");
  73.   leftb->callback(button_cb);
  74.   rightb = new Fl_Toggle_Button(100,75,50,25,"right");
  75.   rightb->callback(button_cb);
  76.   topb = new Fl_Toggle_Button(150,75,50,25,"top");
  77.   topb->callback(button_cb);
  78.   bottomb = new Fl_Toggle_Button(200,75,50,25,"bottom");
  79.   bottomb->callback(button_cb);
  80.   insideb = new Fl_Toggle_Button(250,75,50,25,"inside");
  81.   insideb->callback(button_cb);
  82.   if (!dvisual) Fl::visual(FL_RGB);
  83.   window.resizable(window);
  84.   window.end();
  85.   window.show(argc,argv);
  86.   return Fl::run();
  87. }
  88.  
  89. //
  90. // End of "$Id: pixmap.cxx,v 1.4 1999/01/07 19:17:59 mike Exp $".
  91. //
  92.